IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FormatDatabaseVersion]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[FormatDatabaseVersion]
GO

CREATE FUNCTION [dbo].[FormatDatabaseVersion]
(
	@numericVersion int
)
RETURNS VARCHAR(30)
AS
BEGIN

	declare @version varchar(30)
    set @version = cast(@numericVersion as varchar)
    set @version =
		SUBSTRING(@version, 1, 1) + '.' +
		SUBSTRING(@version, 2, 1) + '.' +
		SUBSTRING(@version, 3, 1) + '.' +
		SUBSTRING(@version, 4, 3)

	return @version
END
GO
